

using Mengsk.ProxyDelivery.Domain;
using NHibernate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mengsk.ProxyDelivery.Dao.HibernateImpl
{
    public class ShoesDao : HibernateDao<Shoes>, IShoesDao
    {
        public Shoes GetFirst(int vendorId)
        {
            using (ISession session = this.OpenSession())
            {
                IQuery hQuery = session.CreateQuery("select top 1 from Shoes where VendorId=?").SetInt32(0, vendorId);
                return hQuery.UniqueResult<Shoes>();
            }
        }

        public string[] GetUrl(int vendorId)
        {
            using (ISession session = this.OpenSession())
            {
                IQuery hQuery = session.CreateQuery("select Url from Shoes where VendorId=?").SetInt32(0, vendorId);
                return hQuery.List<string>().ToArray();
            }
        }

        public IList<Shoes> Get(int vendorId, string number)
        {
            using (ISession session = this.OpenSession())
            {
                IQuery hQuery = session.CreateQuery("from Shoes where VendorId=? and Number=?").SetInt32(0, vendorId).SetString(1, number);
                return hQuery.List<Shoes>();
            }
        }

        public IList<Shoes> Get(int vendorId)
        {
            return this.GetAllByField("VendorId", vendorId);
        }
    }
}
